<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common-app/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>技术合同书编辑</title>
<script type="text/javascript" src="${res}/js/jquery/jquery.form.js"></script>
<script type="text/javascript"
	src="${res}/js/proposal/irisPrpPrepare.js"></script>
<script type="text/javascript"
	src="${res}/js/validate/irisvalidator.js"></script>
<script type="text/javascript"
	src="${res}/js/keyword/keywordtips.js"></script>	
<script type="text/javascript"
	src="${res_app}/js/app/proposal/irisPrpPrepare.js"></script>

<%-- <script src="${res_app}/js/app/kjt/irisdata.js" type="text/javascript"></script>
 --%><style>
	textarea{overflow:auto;}
	.common_select {padding: 3px 1px; border:1px solid #a1c0dc; background-color:#FFF;line-height:24px;height:24px;width:100px; }
</style>

<script type="text/javascript">
$(function(){
	queryflex();
});
/**
 * 申请书提交方法
 */


var ctxpath = "${ctx}";
var prcWin = new progressWin("${res}");//初始化遮罩层
/**
 * 页面初始化方法 所有的都定义在里面
 */

$(document).ready (function() {
	$("#wbox1").click(function() {
		check("check");
		
		
	});
	var bulu = $("#buluvalue").val();
	if(bulu == "bulu"){
		$("#wbox_bulu").click(function() {
			
			check_bulu("check");
			
		});
		$("#wbox_bulu2").click(function() {
			
			check_bulu("check");
			
		});
	}else{

		$("#wbox").click(function() {
			
			check("check");
			
		});
		
		$("#wbox2").click(function() {
			
			check("check");
			
		});
	}
	
	initControl();
	$("table.t_css").not("[id='finances']").not("[id='budgetsMsg2']").each(function(){
		$(this).find("tr:even").addClass("li_1");
		$(this).find("tr:odd").addClass("li_2");
	});
	$("table").addClass("table01");
	$("#checkbox_table_").removeClass("table01");
    $('div').find("[id^='checkbox_dyn_']").find("tr").removeClass("li_1").removeClass("li_2");
    $('div').find("[id^='checkbox_dyn_']").find("td").css("border",'0px solid');
	
	updatePdfNotes();
	window.setInterval("checkPdfStatus()", "10000");//检验申请书的pdf
	
});

$(document).ready(function() {
	//fileInit("feaReport_upload","DOC,DOCX,PDF,WPS");
	fileInit("prpContent_upload","JPG,PDF,TIFF,XLS,DOC,WPS",null,"{'JPG':'51200','PDF':'51200','TIFF':'51200','XLS':'51200','DOC':'51200','WPS':'51200'}");
	
	//fileInitAttach("attachAdd", "JPG,PDF", null, 20, "{'JPG':'3072','PDF':'3072'}");
	$("#prpContent_upload").find(".file").hide();//隐藏文本框
});


$(document).ready(function() {
	$("#org").attr("disabled","true");
	initDepartForComplete("org");
});

/**
 * 申报日期默认为当前日期
 */
$(document).ready(function() {
	 if($("#submit_date").val()==""){
		   $("#submit_date").val("${sercverSysDate1}");
	    }
});

/**
 * 填写检查
 */
function check(type){
	setTotalAmt();
	var org_status=$("#org_status").val();
	if(org_status=='Z'){
		irisValaddMsg("请联系单位管理员完善单位信息，并提交");
	}
	validate($("#fragment-tab1"),"卖方信息-->卖方基本信息");
	validate($("#fragment-tab2"),"买方信息-->买方基本信息");
	var area_code=$("#area_code").val();

	/* if(area_code.length!=0 && area_code.length!=6){
		var num=6-area_code.length;
		irisValaddMsg("买方信息-->买方基本信息-->行政区划代码当前不足6字，还差"+num+"字");
	} */
	validate($("#fragment-tab3"),"合同信息-->合同基本信息");
	var knowType=$("#kr_no_code").val().substr(0,4);
	var reg_no=$("#reg_no").val();
	if(reg_no.length!=0 && reg_no.length!=12){
		var num=12-reg_no.length;
		irisValaddMsg("合同信息-->合同基本信息-->科技成果登记部门批准登记号当前不足12字，还差"+num+"字");
	}
	if(knowType=='0402'){
			var zlsl=parseInt($("#zlsl").val())
			var total=parseInt($("#zlsa").val())+parseInt($("#zlsb").val())+parseInt($("#zlsc").val());
		if(zlsl!=total){
			irisValaddMsg("合同信息-->合同基本信息-->含专利数量=其中含发明专利数量+其中含外观设计专利数量+其中含实用新型专利数量");
		}
	}
	prp_attach();
	validateByTabRow($("#tblJshtZxqk"),'执行情况-->执行情况',0);
	
	//validate($("#fragment-tab5"),"项目绩效目标");
	//附件
	
	if(!valResult()){
		irisValShowMsg($("#wbox1"));
		return false;
	}
	if(type=="check"){
		showBox($("#wbox1"), "300px", "200px", "检查通过","1:所有检查全部合格");
	}
	return true;
}


/**
 * 填写检查
 */
function check_bulu(type){
	
	validateByTabRow($("#tblJshtZxqk"),'执行情况-->执行情况',0);
	
	//validate($("#fragment-tab5"),"项目绩效目标");
	//附件
	
	if(!valResult()){
		irisValShowMsg($("#wbox1"));
		return false;
	}
	if(type=="check"){
		showBox($("#wbox1"), "300px", "200px", "检查通过","1:所有检查全部合格");
	}
	return true;
}


function setTotalAmt(){
	//$('#total_amt').val($("#amt").val());
	//var str=$("#total_amt1").val()/10000;
	//count2 = formatNumberAuto(str.toString(), 9, 4, 2);
	//$('#request_amt').val(count2);
	$('#tech_request_amt').val($("#total_amt1").val());
}

function backToListJsht(){
	window.location.href = ctx + "/tech-ctr/record-technology-list";
}
function backToListJshtAgent(){
	window.location.href = ctx + "/tech-ctr/technology-agent-list?type=init";
}

</script>

<c:if test="${not empty bulu and bulu == 'bulu'}">
<script type="text/javascript">
$(function() {
	setDisabled($("#fragment-tab1"),true);
	setDisabled($("#fragment-tab2"),true);
	setDisabled($("#fragment-tab3"),true);
	setDisabled($("#fragment-tab4"),true);
});

function setDisabled(tabids,flag)
{

	tabids.find("input,textarea,select").not("input[id*='btn_dojoTab']").each(function()
   {
	 
      $(this).attr("disabled",flag);
   });
	
	tabids.find("Img[src$='arrow1.gif']").each(function(){
		$(this).hide();
	});
	
	tabids.find("a[class='link_x']").each(function(){
		var text = $(this).text();
		if(text == '删除'){
			$(this).hide();
		}
	})

	tabids.find(".datepick-trigger").each(function(){
		if(flag) $(this).hide();
		else $(this).show();
			
	});
	
}
</script>
</c:if>

<style>
	textarea{overflow:   auto;}
</style>


</head>
<body>

	<c:set var="xmlstr" value="${xmlData}" />
	<x:parse xml="${xmlstr}" var="xmlData"  scope="request"/>
	<input type="hidden" id="childDiv" class="thickbox"/>
	<input type="hidden" id="filePath" value="${ctx}/file/ajax-filedownload?fileCode=" />
	<input type="hidden" id="menuId" value="${param.menuId}" />
	<input type="hidden" id="sysDate" value="${sercverSysDate}" />
	<input type="hidden" id="buluvalue" value="${bulu }"/>
	
	<div id="showMessage"></div>
	<div id="content">
		
		<cpt:helpTips key="prpedit1" id="prpEditTips"></cpt:helpTips>
		<div class="clear_h15"></div>
		<div class="word_box" id="mainDiv">
			<div class="bar_btn">
				<span class="left"> 
					<c:set var="grantCode"><x:out select="$xmlData/data/proposal/grant_code" /></c:set>
					<c:set var="flag_shizhi"><x:out select="$xmlData/data/proposal/flag_shizhi" /></c:set>
					<input name="Submit" type="button" class="button_01" value="保存" onclick="saveJshtAction()" /> 
					&nbsp; <c:if test="${not empty fbl.pdfViewUrl}"><input name="Submit" type="button" class="button_01" value="下载PDF"  onclick="genPdfAction()"/></c:if>
					
					<c:if test="${empty bulu}">
					&nbsp; <input name="Submit" type="button" class="button_01"	value="提交" onclick="submitJshtAction()" />
					</c:if>
					<c:if test="${isagent != '1'}">
					&nbsp; <input name="Submit" type="button" class="button_01" value="返回" onclick="backToListJsht()" />
					</c:if>
					<c:if test="${isagent == '1'}">
					&nbsp; <input name="Submit" type="button" class="button_01" value="返回" onclick="backToListJshtAgent()" />
					</c:if>
				</span>
				<c:if test="${empty bulu}">
				<span class="right"> 
					<input title="填写检查" class="btn_inspect" type="button" id="wbox"/>
				</span>
				</c:if>
				<c:if test="${not empty bulu}">
				<span class="right"> 
					<input title="填写检查" class="btn_inspect" type="button" id="wbox_bulu"/>
				</span>
				</c:if>
					<c:set var="sub_grant_code"><x:out select="$xmlData/data/proposal/sub_grant_code" /></c:set>
					
			</div>
			<div class="bar_b">
				<input type="hidden" id="pdfStatus" value="${pdfStatus}" />
				<span class="right">版本号：<span name="proposal/prp_version" id="prp_version"><x:out select="$xmlData/data/proposal/prp_version" /></span></span>
			</div>
			<form method="post" id="mainForm">
				<input type="hidden" value="${grantCode}" id="grantCode"
					name="grantCode"> 
				<input type="hidden" value="${posCode}" id="posCode" name="posCode"> 
				<input type="hidden" value="<iris:des3 code="${posCode}"></iris:des3>" id="posCodeDes" name="posCodeDes">
				<input type="hidden" value="<iris:des3 code="${fbl.pdfCode}"></iris:des3>" id="pdfCodeDes" name="pdfCodeDes">  
				<input type="hidden" value="${xmlData}" id="xmlData" name="xmlData">
				<input type="hidden" value="${fbl.pdfCode}" id="pdfCode" name="pdfCode"> 
				<input type="hidden" value="${flag_shizhi}" id="flag_shizhi" name="proposal/flag_shizhi"> 
				<input type="hidden" value="${isagent }" id="isagent" name="isagent"> 
			</form>
				<div class="word_title">
					
					<c:set var="statYear">${statYear}</c:set>
					<c:if test="${empty statYear}">
						<c:set var="statYear"><x:out select="$xmlData/data/proposal/stat_year" /></c:set>
					</c:if>
					<input type="hidden" name="proposal/org_status" id="org_status" value="<x:out select="$xmlData/data/proposal/org_status" />" />
					<input type="hidden" name="proposal/stat_year" value="${statYear}">
					<span name="proposal/grant_name" ><x:out select="$xmlData/data/proposal/grant_name" /></span> (<span name="proposal/stat_year">${statYear}</span>年)<br />	
					<input type="hidden" name="proposal/sub_grant_name" value="<x:out select="$xmlData/data/proposal/sub_grant_name" />" />
					<input type="hidden" name="proposal/fzr_tel" value="<x:out select="$xmlData/data/organization_persons/organization_person[@psn_type='lianxiren']/contact_tel" />"/>	
					<input type="hidden" name="proposal/fzr_mobile" value="<x:out select="$xmlData/data/organization_persons/organization_person[@psn_type='lianxiren']/contact_mobile" />"/>	

					<input type="hidden" name="proposal/grant_code" value="<x:out select="$xmlData/data/proposal/grant_code" />" />  <input type="hidden" name="proposal/psn_code" value="<x:out select="$xmlData/data/proposal/psn_code" />" />
					<input type="hidden" id="grant_no" name="proposal/grant_no" value="<x:out select="$xmlData/data/proposal/grant_no" />" />							
					<input type="hidden" name="proposal/sub_grant_code" value="<x:out select="$xmlData/data/proposal/sub_grant_code" />" />
					<input name="proposal/register_area_code" type="hidden" value="<x:out select="$xmlData/data/organizations/organization[@submit_org='1']/area_value" />" />
		            <input name="proposal/register_area_name" type="hidden" value="<x:out select="$xmlData/data/organizations/organization[@submit_org='1']/area_name" />" />
					<input type="hidden" id="sub_grant_no" name="proposal/sub_grant_no" value="<x:out select="$xmlData/data/proposal/sub_grant_no" />" />
					<input type="hidden" name="proposal/help_grant_code" value="<x:out select="$xmlData/data/proposal/help_grant_code" />" />
					<input type="hidden" id="help_grant_no" name="proposal/help_grant_no" value="<x:out select="$xmlData/data/proposal/help_grant_no" />" />
					<c:set var="formCode"><x:out select="$xmlData/data/proposal/form_code" /></c:set>
					<c:set var="nature_value"><x:out select="$xmlData/data/organizations/organization[@submit_org='1']/nature_value" /> </c:set>
					<c:if test="${empty formCode}"><c:set var="formCode" value="${param.formCode}"></c:set></c:if>
					<input type="hidden" name="proposal/form_code" value="${formCode}" />
				    <input type="hidden" name="proposal/tech_request_amt" 
							id="tech_request_amt" value="<x:out select="$xmlData/data/proposal/tech_request_amt"/>">
												<input type="hidden" name="proposal/year" value="${year}" />
												 <input type="hidden"
					name="organizations/organization[0]@submit_org" value="1">
					<input type="hidden" name="organizations/organization[0]/org_code"
					value="<x:out select="$xmlData/data/organizations/organization[@submit_org=1]/org_code"/>">
						
				 <!-- 公用的配置界面 -->
				    <jsp:include page="./prpeditmain_jsht_head.jsp"></jsp:include>
				</div>
				
				<c:set var="type_flag">${ type}</c:set>
				<c:if test="${empty type_flag  or  type_flag eq '' }">
					<c:set var="type_flag"><x:out select="$xmlData/data/proposal/type" /></c:set>
				</c:if>
				<input type="hidden" id="type" name="proposal/type" value="${type_flag }" />
				
				<div id="tabnav">
					<ul>
						<c:if test="${empty bulu}">
						<li id="tab1" onclick="changeTab(this.id)">
						    <a href="###"><span>卖方信息</span></a>
						</li>
						</c:if>
						<c:if test="${not empty bulu and bulu == 'bulu'}">
						<li id="tab1" onclick="changeTab(this.id)">
						    <a href="###"><span>卖方信息</span></a>
						</li>
						</c:if>
						
						<li id="tab2" onclick="changeTab(this.id)">
						    <a href="###"><span>买方信息</span></a>
						</li>
						<c:if test="${empty bulu}">
							<li id="tab3"  class="down" onclick="changeTab(this.id)" >
							    <a href="###"><span>合同信息</span></a>
							</li>
						</c:if>
						<c:if test="${not empty bulu and bulu == 'bulu'}">
							<li id="tab3"  onclick="changeTab(this.id)" >
							    <a href="###"><span>合同信息</span></a>
							</li>
						</c:if>
						
						
						<li id="tab4" onclick="changeTab(this.id)" >
						    <a href="###"><span>附件清单</span></a>
						</li>
						
						<c:if test="${empty bulu}">
						<li id="tab5" onclick="changeTab(this.id)" >
						    <a href="###"><span>执行情况</span></a>
						</li>
						</c:if>
						<c:if test="${not empty bulu and bulu == 'bulu'}">
						<li class="down" id="tab5" onclick="changeTab(this.id)">
						     <a href="###"><span>执行情况</span></a>
						</li>
						</c:if>
					
					</ul>
				</div>
				
				
				<!-- 点击卖方方申请 初始化卖方方信息  -->
				<c:if test="${ type_flag eq 'sell' }">
						<c:if test="${empty bulu}">
						<div class="tab_box" id="fragment-tab1" style="display: none">
							<jsp:include page="../org/prporg_jsht_org2.jsp">
								<jsp:param value="${xmlstr}" name="xmlstr" />
								<jsp:param value="${grantName}" name="grantName" />
							</jsp:include>
						</div>
						</c:if>
						<c:if test="${not empty bulu and bulu == 'bulu'}">
						<div class="tab_box" id="fragment-tab1" style="display: none">
							<jsp:include page="../org/prporg_jsht_org2.jsp">
								<jsp:param value="${xmlstr}" name="xmlstr" />
								<jsp:param value="${grantName}" name="grantName" />
							</jsp:include>
						</div>
						</c:if>
						
						<div class="tab_box" id="fragment-tab2" style="display: none">
							<jsp:include page="../org/prporg_jsht_org1.jsp">
								<jsp:param value="${xmlstr}" name="xmlstr" />
							</jsp:include>
						</div>
						<c:if test="${empty bulu}">
							<div class="tab_box" id="fragment-tab3" >
								<jsp:include page="../info/prpInfoEdit_jsht.jsp">
									<jsp:param value="${xmlstr}" name="xmlstr" />
								</jsp:include>
							</div>
						</c:if>
						<c:if test="${not empty bulu and bulu == 'bulu'}">
							<div class="tab_box" id="fragment-tab3" style="display: none" >
								<jsp:include page="../info/prpInfoEdit_jsht.jsp">
									<jsp:param value="${xmlstr}" name="xmlstr" />
								</jsp:include>
							</div>
						</c:if>
						
						<div class="tab_box" id="fragment-tab4" style="display: none">
							<jsp:include page="../attach/prpAttachEdit_by_jsht.jsp">
							    <jsp:param value="${xmlstr}" name="xmlstr" />
							</jsp:include>
						</div>
						<c:if test="${empty bulu}">
						<div class="tab_box" id="fragment-tab5" style="display: none">
							<jsp:include page="../info/prpInfoEdit_jsht_zxqk.jsp">
								<jsp:param value="${xmlstr}" name="xmlstr" />
							</jsp:include>
						</div>
						</c:if>
						<c:if test="${not empty bulu and bulu == 'bulu'}">
							<div class="tab_box" id="fragment-tab5">
								<jsp:include page="../info/prpInfoEdit_jsht_zxqk.jsp">
									<jsp:param value="${xmlstr}" name="xmlstr" />
								</jsp:include>
							</div>
						</c:if>
				</c:if>
				
				
				<!-- 点击买方方申请 所有页面 初始化买方申请  -->
				<c:if test="${type_flag eq 'buy' }">
						<c:if test="${empty bulu}">
						<div class="tab_box" id="fragment-tab2" style="display: none">
							<jsp:include page="../org/prporg_jsht_org1_1.jsp">
								<jsp:param value="${xmlstr}" name="xmlstr" />
								<jsp:param value="${grantName}" name="grantName" />
							</jsp:include>
						</div>
						</c:if>
						<c:if test="${not empty bulu and bulu == 'bulu'}">
						<div class="tab_box" id="fragment-tab2" style="display: none">
							<jsp:include page="../org/prporg_jsht_org1_1.jsp">
								<jsp:param value="${xmlstr}" name="xmlstr" />
								<jsp:param value="${grantName}" name="grantName" />
							</jsp:include>
						</div>
						</c:if>
						
						<div class="tab_box" id="fragment-tab1" style="display: none">
							<jsp:include page="../org/prporg_jsht_org2_2.jsp">
								<jsp:param value="${xmlstr}" name="xmlstr" />
							</jsp:include>
						</div>
						
						<c:if test="${empty bulu}">
							<div class="tab_box" id="fragment-tab3" >
								<jsp:include page="../info/prpInfoEdit_jsht.jsp">
									<jsp:param value="${xmlstr}" name="xmlstr" />
								</jsp:include>
							</div>
						</c:if>
						<c:if test="${not empty bulu and bulu == 'bulu'}">
							<div class="tab_box" id="fragment-tab3" style="display: none" >
								<jsp:include page="../info/prpInfoEdit_jsht.jsp">
									<jsp:param value="${xmlstr}" name="xmlstr" />
								</jsp:include>
							</div>
						</c:if>
						<div class="tab_box" id="fragment-tab4" style="display: none">
							<jsp:include page="../attach/prpAttachEdit_by_jsht.jsp">
							    <jsp:param value="${xmlstr}" name="xmlstr" />
							</jsp:include>
						</div>
						<c:if test="${empty bulu}">
						<div class="tab_box" id="fragment-tab5" style="display: none">
							<jsp:include page="../info/prpInfoEdit_jsht_zxqk.jsp">
								<jsp:param value="${xmlstr}" name="xmlstr" />
							</jsp:include>
						</div>
						</c:if>
						<c:if test="${not empty bulu and bulu == 'bulu'}">
							<div class="tab_box" id="fragment-tab5">
								<jsp:include page="../info/prpInfoEdit_jsht_zxqk.jsp">
									<jsp:param value="${xmlstr}" name="xmlstr" />
								</jsp:include>
							</div>
						</c:if>
				</c:if>
				
			<div class="bar_btn02">
				<span class="left"> 
					<input name="Submit" type="button" class="button_01" value="保存" onclick="saveJshtAction()" /> 
					&nbsp; <c:if test="${not empty fbl.pdfViewUrl}"><input name="Submit" type="button" class="button_01" value="下载PDF"  onclick="genPdfAction()"/></c:if>
					 <c:if test="${empty bulu}">
					 <input name="Submit" type="button" class="button_01"	value="提交" onclick="submitJshtAction()" />
					</c:if>
					<c:if test="${isagent != '1'}">
					&nbsp; <input name="Submit" type="button" class="button_01" value="返回" onclick="backToListJsht()" />
					</c:if>
					<c:if test="${isagent == '1'}">
					&nbsp; <input name="Submit" type="button" class="button_01" value="返回" onclick="backToListJshtAgent()" />
					</c:if>
				</span>
				<c:if test="${empty bulu}">
				<span class="right"> 
					<input title="填写检查" class="btn_inspect" type="button" id="wbox2"/>
				</span>
				</c:if>
				<c:if test="${not empty bulu}">
				<span class="right"> 
					<input title="填写检查" class="btn_inspect" type="button" id="wbox_bulu2"/>
				</span>
				</c:if>
		
			</div>
		</div>
		<div class="clear_h15"></div>
	</div>
</body>

</html>